<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>适合打劫银行的日子</title>
</head>
<body>
  <script>
    function fn(arr, time) {
      let n = arr.length;
      let left = new Array(n).fill(0);
      let right = new Array(n).fill(0);
      for (let i = 1; i < n; i++) {
        if (arr[i] <= arr[i - 1]) {
          left[i] = left[i - 1] + 1;
        }
        if (arr[n - i - 1] <= arr[n - i]) {
          right[n - i - 1] = right[n - i] + 1;
        }
      }
      let ans = [];
      for (let i = time; i < n - time; i++) {
        if (left[i] >= time && right[i] >= time) {
          ans.push(i);
        }
      }
      return ans;
    }
    console.log(fn([5, 3, 3, 3, 5, 6, 2], 2))
  </script>
</body>
</html>